//
//  TTEmptyImageTool.m
//  Perking
//
//  Created by tim on 16/7/13.
//  Copyright © 2016年 tim. All rights reserved.
//

#import "TTEmptyImageTool.h"
#import "UILabel+Size.h"

@implementation TTEmptyImageTool

-(id)initWithTitle:(NSString *)labTitle image:(NSString *)image {
    self = [super init];
    if (self) {
        _iconImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:image]];
        [self addSubview:_iconImg];
        
        UILabel *lab = [[UILabel alloc] init];
        lab.text = labTitle;
        lab.textAlignment = NSTextAlignmentCenter;
        lab.textColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.3];
        lab.font = [UIFont systemFontOfSize:16];
        lab.size = [lab lm_sizeWithMargin:130 * __kwRatio];
        lab.centerX = __kScreenWidth * 0.5;
        lab.top = (__kScreenHeight - 64) * 0.5;
        lab.numberOfLines = 0;
        [self addSubview:lab];
        _iconImg.centerX = lab.centerX;
        _iconImg.bottom = lab.top - 15;
        self.width = __kScreenWidth;
        self.height = __kScreenHeight - 64;
        self.backgroundColor = [UIColor whiteColor];
    }
    
    return self;
}

-(id)initWithTitle:(NSString *)labTitle withSubtitle:(NSString*)subtitle{
    self = [super init];
    if (self) {
        _iconImg = [[UIImageView alloc] init];
        [self addSubview:_iconImg];
        
        UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(__kScreenWidth/4-60, (__kScreenHeight-20)/2, __kScreenWidth/2+120, 20)];
        lab.text = labTitle;
        lab.textAlignment = NSTextAlignmentCenter;
        lab.textColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.3];
        lab.font = [UIFont systemFontOfSize:16];
        [self addSubview:lab];
        
        UILabel *subLable = [[UILabel alloc] initWithFrame:CGRectMake(__kScreenWidth/4-60, lab.bottom+5, __kScreenWidth/2+120, 20)];
        subLable.text = subtitle;
        subLable.textAlignment = NSTextAlignmentCenter;
        subLable.textColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.3];
        subLable.font = [UIFont systemFontOfSize:12];
        [self addSubview:subLable];
    }
    
    return self;
}

@end
